package com.xjlsoft.weather.task;


import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import com.xjlsoft.weather.exception.WeatherException;
import com.xjlsoft.weather.service.WeatherTaskJob;
import com.xjlsoft.weather.util.WeatherDataUtil;

/**
 * 定时删除   excel导出  文件
 *
 * @author 码农猿
 */
public class ExportFileDeleteTask implements WeatherTaskJob {

    /**
     * 日志
     */
    private static final Logger logger = LoggerFactory.getLogger(ExportFileDeleteTask.class);

    
    @Value("${excelfilePortPrefix}")
	private String excelfilePortPrefix;

	@Value("${excelfile}")
	private String excelfile;
    
   // @Scheduled(cron="0 0 8 ? * MON")   定时删除文件    没周一 早上8点 执行

    @Override
    public void run() {
    	
    	logger.info("=====开始删除，excel导出 文件============");
		File filePath=new File(excelfilePortPrefix+File.separator+excelfile);
		int result=0;
		try {
			result = WeatherDataUtil.deleteFile(filePath);
		}catch (WeatherException weatherException) {
			logger.info(weatherException.getErrorMsg());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		logger.info("======删除文件数量:"+result+"=======");
    	
    }
}